Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add Namespace Scoped Zone Discovery and Watch #3146

Merged
merged 3 commits into from
Aug 13, 2024

Conversation

zhanggbj
Copy link
Contributor

@zhanggbj zhanggbj commented Aug 8, 2024

What this PR does / why we need it:
This is to support the new Namespace Scoped Zone for isolation.

  • Introduce a feature flag to enable Namespace Scoped Zone.
  • Enhance zone discovery to support Namespace Scoped Zones.
  • Filter out zones marked for deletion during the discovery process.
  • Add Watch for Zone changes to update FailureDomains accordingly

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 8, 2024
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Aug 8, 2024
@zhanggbj zhanggbj marked this pull request as draft August 8, 2024 08:41
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 8, 2024
@zhanggbj zhanggbj force-pushed the add_zone_ds branch 3 times, most recently from 4247967 to e19a5cd Compare August 8, 2024 09:46
@sbueringer
Copy link
Member

@zhanggbj Should we already take a look or wait until the PR is out of draft?

@zhanggbj zhanggbj marked this pull request as ready for review August 8, 2024 10:17
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 8, 2024
@zhanggbj
Copy link
Contributor Author

zhanggbj commented Aug 8, 2024

@sbueringer @chrischdi @fabriziopandini
Just removed the WIP as I was fixing some test job errors, but feel free to start a review, thanks!

About testing results with a real supervisor:

  1. With a Supervisor which has both Cluster scoped AZ (zone-1, zone-2 and zone-3)and NS scoped Zone (zone-2 and zone-3), with NamespaceScopedZone enabled, cluster creation completes successfully.
tkg-test    tkg-multizone-e-drr4s-kpl8m                     zone-2   vsphere://302b8630-234d-4870-9ba6-0440fa2bf00e   192.168.128.77
tkg-test    tkg-multizone-e-drr4s-svwcc                     zone-3   vsphere://1c295476-e071-4d31-b737-7e30467650e3   192.168.128.74
tkg-test    tkg-multizone-e-drr4s-v7wzr                     zone-2   vsphere://ebb2f15d-5196-4dc7-88e5-fac9f6ced243   192.168.128.73
tkg-test    tkg-multizone-e-worker-np-1-2plnn-4jj56-f5jgl   zone-2   vsphere://cecc5158-90d8-4226-9af8-165d9d4f3f7c   192.168.128.76
tkg-test    tkg-multizone-e-worker-np-3-8kw7k-vnq7j-mw8p5   zone-3   vsphere://e1cda4ef-1826-4347-a9e0-740e61716237   192.168.128.75
  1. With a Supervisor which has both Cluster scoped AZ (zone-1, zone-2 and zone-3)and NS scoped Zone (zone-2 and zone-3), with NamespaceScopedZone disabled, CAPV will discover Cluster scoped AZ zone-1, zone-2 and zone-3 as expected.

Copy link
Member

@chrischdi chrischdi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need to add a watch ca. at:
https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/blob/main/controllers/vspherecluster_controller.go#L75

But only if the featuregate is enabled.

It should then use a EnqueueRequestFromMapFunc for all clusters in the namespace where the zone change was detected.

controllers/vmware/vspherecluster_reconciler.go Outdated Show resolved Hide resolved
controllers/vmware/vspherecluster_reconciler.go Outdated Show resolved Hide resolved
controllers/vmware/vspherecluster_reconciler.go Outdated Show resolved Hide resolved
feature/feature.go Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
external/tanzu-topology/api/v1alpha1/groupversion_info.go Outdated Show resolved Hide resolved
controllers/vmware/vspherecluster_reconciler_test.go Outdated Show resolved Hide resolved
@zhanggbj
Copy link
Contributor Author

zhanggbj commented Aug 9, 2024

We also need to add a watch ca. at: main/controllers/vspherecluster_controller.go#L75

But only if the featuregate is enabled.

It should then use a EnqueueRequestFromMapFunc for all clusters in the namespace where the zone change was detected.

Sure, we need to watch the Zone event, but I was planning to add it in a separate PR, as so far I cannot test it locally as the supervisor hasn't fully supported Zone deletion.

Currently only Zone discovery and cluster creation can be tested.

@sbueringer
Copy link
Member

sbueringer commented Aug 9, 2024

I really would prefer adding the watch in this PR already, even if we can't manually test it. Although it's not clear to me why we can't test it. Basically you can add/remove Zone objects and these should be then reflected in VSphereCluster and directly afterwards on Cluster, right?
(they don't even have to work to test that)

@zhanggbj
Copy link
Contributor Author

zhanggbj commented Aug 9, 2024

Have to add a dot after this line, otherwise godot linter will fail Comment should end in a period (godot) and seems I cannot add a //nolint:godot in a commented line.

// SPDX-License-Identifier: Apache-2.0

@zhanggbj
Copy link
Contributor Author

zhanggbj commented Aug 9, 2024

@chrischdi @sbueringer
I'm OK to add the Watch in this PR for code review first, I'll test it later locally, just want to make sure code changes are tested with the supervisor before sending for review.

@chrischdi
Copy link
Member

Have to add a dot after this line, otherwise godot linter will fail Comment should end in a period (godot) and seems I cannot add a //nolint:godot in a commented line.

// SPDX-License-Identifier: Apache-2.0

Let's add a global ignore to this path in .golangci.yaml

Should then be something like:

  skip-files:
    - "zz_generated.*\\.go$"
    - "_conversion\\.go$"
    - "vendored_cluster_api\\.go$"
    - "^internal/apis/topology/v1alpha1"

@zhanggbj zhanggbj force-pushed the add_zone_ds branch 2 times, most recently from 404ed05 to 73e4950 Compare August 9, 2024 08:37
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 13, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 73bebc55504d8679c600b53018c2cd01d0629ff6

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 13, 2024
@sbueringer
Copy link
Member

sbueringer commented Aug 13, 2024

/assign @chrischdi

for a final review

Copy link
Member

@chrischdi chrischdi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve
/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 13, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chrischdi, sbueringer

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [chrischdi,sbueringer]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 13, 2024
@sbueringer
Copy link
Member

/hold
for another round of tests on the mirror :)

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 13, 2024
zhanggbj and others added 2 commits August 13, 2024 16:39
- Introduce a feature flag to enable Namespace Scoped Zone.
- Enhance zone discovery to support Namespace Scoped Zones.
- Filter out zones marked for deletion during the discovery process.
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 13, 2024
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 13, 2024
@chrischdi
Copy link
Member

/lgtm

/test help

@k8s-ci-robot
Copy link
Contributor

@chrischdi: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test pull-cluster-api-provider-vsphere-e2e-vcsim-govmomi-main
  • /test pull-cluster-api-provider-vsphere-e2e-vcsim-supervisor-main
  • /test pull-cluster-api-provider-vsphere-test-main
  • /test pull-cluster-api-provider-vsphere-verify-main

The following commands are available to trigger optional jobs:

  • /test pull-cluster-api-provider-vsphere-apidiff-main

Use /test all to run the following jobs that were automatically triggered:

  • pull-cluster-api-provider-vsphere-apidiff-main
  • pull-cluster-api-provider-vsphere-test-main
  • pull-cluster-api-provider-vsphere-verify-main

In response to this:

/lgtm

/test help

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 13, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 09e4e29248e364c519a92078215bfb1640c9f861

@chrischdi
Copy link
Member

/test pull-cluster-api-provider-vsphere-e2e-vcsim-govmomi-main
/test pull-cluster-api-provider-vsphere-e2e-vcsim-supervisor-main

@chrischdi
Copy link
Member

/hold

Waiting for jobs here and at team-cluster-api#7 to succeed

@sbueringer
Copy link
Member

Tests are green.

Nice work everyone!

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 13, 2024
@k8s-ci-robot k8s-ci-robot merged commit 4f8d638 into kubernetes-sigs:main Aug 13, 2024
14 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.11 milestone Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants